﻿namespace EasyWeb.Web.UI
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Web.Helpers;

    public class EWGridPagingBuilder<TModel>
    {
        public EWGridPagingBuilder(EWGrid<TModel> grid)
        {
            EWGuard.IsNotNull(grid, "grid");
            this.Component = grid;
        }

        public EWGrid<TModel> Component { get; private set; }

        public EWGridPagingBuilder<TModel> RowsPerPage(int value)
        {
            EWGuard.IsNotZeroOrNegative(value, "value");
            this.Component.RowsPerPage = value;
            return this;
        }

        public EWGridPagingBuilder<TModel> PageFieldName(string value)
        {
            this.Component.PageFieldName = value;
            return this;
        }

        public EWGridPagingBuilder<TModel> PagerMode(EWGridPagerModes value)
        {
            EWGuard.IsDefinedEnum(value, "value");
            this.Component.PagerMode = value;
            return this;
        }

        public EWGridPagingBuilder<TModel> NumericLinksCount(int value)
        {
            EWGuard.IsNotZeroOrNegative(value, "value");
            this.Component.NumericLinksCount = value;
            return this;
        }

        public EWGridPagingBuilder<TModel> FirstText(string value)
        {
            this.Component.FirstText = value;
            return this;
        }

        public EWGridPagingBuilder<TModel> PreviousText(string value)
        {
            this.Component.PreviousText = value;
            return this;
        }

        public EWGridPagingBuilder<TModel> NextText(string value)
        {
            this.Component.NextText = value;
            return this;
        }

        public EWGridPagingBuilder<TModel> LastText(string value)
        {
            this.Component.LastText = value;
            return this;
        }
    }
}
